﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PolePosition.v3.Desktop.Selectors
{
    public partial class SelectProject : DialogBase, IDialogBase
    {
        public SelectProject()
        {
            InitializeComponent();
        }

        #region Asynch Processing (Implements IDialogBase)

        //to start the asynch background worker call - base.StartAsynchWork()

        public override void DoAsynchWork(DoWorkEventArgs e)
        {
            //do whatever needs to be done asynch here (BackgroudWorker_DoWork)


        }

        public override void AsychWorkComplete(object sender, RunWorkerCompletedEventArgs e)
        {
            base.AsychWorkComplete(sender, e);
            //do whatever needs to be done after asynch work complete (BackgroudWorker_RunWorkerCompleted)


        }


        #endregion

        private void SelectProject_Load(object sender, EventArgs e)
        {
            EntityLibrary.ProjectEntity _DefaultProject;
            _DefaultProject = Program.UserSelections.VendorSelectedProject;

            if (_DefaultProject == null)
                return;

            List<EntityLibrary.ProjectEntity> _List = new List<EntityLibrary.ProjectEntity>();
            _List.Add(_DefaultProject);
            
            projects1.SelectedProjects = _List;
        }

        private void buttonXOk_Click(object sender, EventArgs e)
        {
            List<EntityLibrary.ProjectEntity> _Projects;
            _Projects = projects1.SelectedProjects;

            if (_Projects == null || _Projects.Count == 0)
                Program.UserSelections.VendorSelectedProject = null;
            else
                Program.UserSelections.VendorSelectedProject = _Projects[0];

            this.DialogResult = DialogResult.OK;
        }
    }
}
